Skip to main content

Smooth Data

smooth(input: any[] | Mat | Tensor, dim: Number) : any[] | Mat | Tensor

param input - a matrix, or Mat only supporting 2d. This is the input to smooth the data of.

param dim EITHER '0' or '1', 0 for rows, 1 for columns. Default is rows, or 0.

returns: any[] | Mat | Tensor - the input with the elements smoothed

This function smooths the data by the following method: a[i] -> (a[i - 2] + a[i - 1] + a[i] + a[i + 1] + a[i + 2]) / 5

An example to make it clearer is shown below. Its useful for cases where the data is very noisy in large data sets, or where there are many outliers.

Overall it tries to make the data all "closer" together.